<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>AdWords::V2009HeaderHandler</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
    <script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>     
    <div class="banner">
        <h1>
            <span class="type">Class</span> 
            AdWords::V2009HeaderHandler 
            
                <span class="parent">&lt; 
                    
                    SOAP::Header::SimpleHandler
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/lib/adwords4r/credentials_rb.html">lib/adwords4r/credentials.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
    
    <div class="description">
        <p>
Handles the headers used in v2009 requests.
</p>

    </div>
    

    

    
    

    
    
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
    
        <dt>N</dt>
        <dd>
            <ul>
                
                <li><a href="#M000003">new</a></li>
                
            </ul>
        </dd>
    
        <dt>O</dt>
        <dd>
            <ul>
                
                <li><a href="#M000004">on_simple_outbound</a></li>
                
            </ul>
        </dd>
    
    </dl>
    

    

    

    

    

    

    
            <div class="sectiontitle">Class Public methods</div>
            
            <div class="method">
                <div class="title" id="M000003">
                    
                    <a name="M000003"></a><b>new</b>(parent, namespace, version)
                    
                </div>
                
                <div class="description">
                  <p>
Constructor for <a href="V2009HeaderHandler.html">V2009HeaderHandler</a>.
</p>
<p>
Args:
</p>
<ul>
<li>parent: <a href="AdWordsCredentials.html">AdWordsCredentials</a> object
containing the login credentials.

</li>
</ul>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('M000003_source')" id="l_M000003_source">show</a>
                        
                    </p>
                    <div id="M000003_source" class="dyn-source">
                        <pre><span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 40</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">parent</span>, <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">version</span>)
      <span class="ruby-keyword kw">super</span>(<span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-value str">'RequestHeader'</span>))
      <span class="ruby-ivar">@parent</span> = <span class="ruby-identifier">parent</span>
      <span class="ruby-ivar">@version</span> = <span class="ruby-identifier">version</span>
    <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="sectiontitle">Instance Public methods</div>
            
            <div class="method">
                <div class="title" id="M000004">
                    
                    <a name="M000004"></a><b>on_simple_outbound</b>()
                    
                </div>
                
                <div class="description">
                  <p>
Handles callback.
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show</a>
                        
                    </p>
                    <div id="M000004_source" class="dyn-source">
                        <pre><span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 47</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_simple_outbound</span>
      <span class="ruby-identifier">ns</span> = <span class="ruby-constant">HEADER_NAMESPACE</span>
      <span class="ruby-identifier">ns</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">'v'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@version</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Integer</span>
      <span class="ruby-identifier">ns</span> <span class="ruby-operator">+=</span> <span class="ruby-ivar">@version</span>.<span class="ruby-identifier">to_s</span>
      <span class="ruby-identifier">header</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>)
      <span class="ruby-identifier">auth_token</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ns</span>, <span class="ruby-value str">'authToken'</span>),
          <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">auth_token</span>)
      <span class="ruby-identifier">user_agent</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ns</span>, <span class="ruby-value str">'userAgent'</span>),
          <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">credentials</span>[<span class="ruby-value str">'userAgent'</span>])
      <span class="ruby-identifier">dev_token</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ns</span>, <span class="ruby-value str">'developerToken'</span>),
          <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">credentials</span>[<span class="ruby-value str">'developerToken'</span>])
      <span class="ruby-identifier">header</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">auth_token</span>)
      <span class="ruby-identifier">header</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">user_agent</span>)
      <span class="ruby-identifier">header</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">dev_token</span>)

      <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">credentials</span>[<span class="ruby-value str">'applicationToken'</span>]
        <span class="ruby-identifier">app_token</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ns</span>,
            <span class="ruby-value str">'applicationToken'</span>), <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">credentials</span>[<span class="ruby-value str">'applicationToken'</span>])
        <span class="ruby-identifier">header</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">app_token</span>)
      <span class="ruby-keyword kw">end</span>

      <span class="ruby-identifier">client_email_value</span> = <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">client_email</span>
      <span class="ruby-identifier">client_cid_value</span> = <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">client_customer_id</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">client_email_value</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">client_email_value</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
        <span class="ruby-identifier">client_email</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ns</span>, <span class="ruby-value str">'clientEmail'</span>),
            <span class="ruby-identifier">client_email_value</span>)
        <span class="ruby-identifier">header</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">client_email</span>)
      <span class="ruby-keyword kw">end</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">client_cid_value</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">client_cid_value</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
        <span class="ruby-identifier">client_cid</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(
            <span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ns</span>, <span class="ruby-value str">'clientCustomerId'</span>), <span class="ruby-identifier">client_cid_value</span>)
        <span class="ruby-identifier">header</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">client_cid</span>)
      <span class="ruby-keyword kw">end</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">validate_only</span>
        <span class="ruby-identifier">validate_only</span> = <span class="ruby-constant">SOAP</span><span class="ruby-operator">::</span><span class="ruby-constant">SOAPElement</span>.<span class="ruby-identifier">new</span>(
            <span class="ruby-constant">XSD</span><span class="ruby-operator">::</span><span class="ruby-constant">QName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ns</span>, <span class="ruby-value str">'validateOnly'</span>), <span class="ruby-value str">'true'</span>)
        <span class="ruby-identifier">header</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">validate_only</span>)
      <span class="ruby-keyword kw">end</span>
      <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">header</span>
    <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
</div>
    </div>
  </body>
</html>    